<?php
namespace RMD\AccountBundle\Entity;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;

use Doctrine\Common\Collections\ArrayCollection;
class GroupSet
{
	const SIGLE_CHOICE = 1;
	const MULTI_CHOICE = 2;

	private $id;
	private $lists_id;
	private $title;
	private $selectType;
	private $dateCreated;

	protected $list;
	protected $groups;
	public function __construct() {
		$this->groups = new ArrayCollection();
	}
	
    public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        //$metadata->addConstraint(new UniqueEntity(array('fields' => array('email'))));

		$metadata->addPropertyConstraint('title', new Assert\NotBlank());
        $metadata->addPropertyConstraint('title', new Assert\Length(array("max" => 50)));
        
        $metadata->addPropertyConstraint('selectType', new Assert\NotBlank());
		$metadata->addPropertyConstraint('selectType', new Assert\Choice(array(
            'choices' => array(self::SIGLE_CHOICE, self::MULTI_CHOICE),
            'message' => 'Choose a valid select type',
        )));
    }


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set lists_id
     *
     * @param integer $listsId
     * @return GroupSet
     */
    public function setListsId($listsId)
    {
        $this->lists_id = $listsId;
    
        return $this;
    }

    /**
     * Get lists_id
     *
     * @return integer 
     */
    public function getListsId()
    {
        return $this->lists_id;
    }

    /**
     * Set title
     *
     * @param string $title
     * @return GroupSet
     */
    public function setTitle($title)
    {
        $this->title = $title;
    
        return $this;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set selectType
     *
     * @param integer $selectType
     * @return GroupSet
     */
    public function setSelectType($selectType)
    {
        $this->selectType = $selectType;
    
        return $this;
    }

    /**
     * Get selectType
     *
     * @return integer 
     */
    public function getSelectType()
    {
        return $this->selectType;
    }

    /**
     * Set dateCreated
     *
     * @param \DateTime $dateCreated
     * @return GroupSet
     */
    public function setDateCreated($dateCreated)
    {
        $this->dateCreated = $dateCreated;
    
        return $this;
    }

    /**
     * Get dateCreated
     *
     * @return \DateTime 
     */
    public function getDateCreated()
    {
        return $this->dateCreated;
    }

    /**
     * Set list
     *
     * @param \RMD\AccountBundle\Entity\Lists $list
     * @return GroupSet
     */
    public function setList(\RMD\AccountBundle\Entity\Lists $list = null)
    {
        $this->list = $list;
    
        return $this;
    }

    /**
     * Get list
     *
     * @return \RMD\AccountBundle\Entity\Lists 
     */
    public function getList()
    {
        return $this->list;
    }

    /**
     * Add groups
     *
     * @param \RMD\AccountBundle\Entity\Group $groups
     * @return GroupSet
     */
    public function addGroup(\RMD\AccountBundle\Entity\Group $groups)
    {
        $this->groups[] = $groups;
		$groups->setGroupSet($this);
        return $this;
    }

    /**
     * Remove groups
     *
     * @param \RMD\AccountBundle\Entity\Group $groups
     */
    public function removeGroup(\RMD\AccountBundle\Entity\Group $groups)
    {
        $this->groups->removeElement($groups);
    }

    /**
     * Get groups
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getGroups()
    {
        return $this->groups;
    }
	public function setGroups($groups){
		//var_dump($groups);
	}
	public function getSelectTypeText(){
		if ($this->selectType == self::SIGLE_CHOICE) {
			return 'Single';
		} else {
			return 'Multiple';
		}
	}
}